/**
 * 基于缓存，定义常用方法
 */
import { setItem, getItem, removeItem, removeAllItem } from "./storage";

export const TOKEN_KEY = "token";

export const clearCache = () => {
  removeAllItem();
};

export const setToken = (token) => {
  setItem(TOKEN_KEY, token);
};

export const getToken = () => {
  const token = getItem(TOKEN_KEY);
  if (token) {
    return token;
  } else {
    return false;
  }
};

export const clearToken = () => {
  removeItem(TOKEN_KEY);
};
